<template>
  <div id="circlegeometry"></div>
</template>

<script setup lang="ts">
import { onMounted } from 'vue'
import * as THREE from 'three'
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js'

const scene = new THREE.Scene()

const geometry = new THREE.CircleGeometry(5, 30, 5, 7)
const humbelMaterial = new THREE.MeshBasicMaterial({
  color: 'wihte',
  wireframe: true,
})
const solidMaterial = new THREE.MeshBasicMaterial({
  color: '#2b7098',
  transparent: true,
  opacity: 0.8,
  side: THREE.DoubleSide // 此时设置为双面显示
})
const humbelMesh = new THREE.Mesh(geometry, humbelMaterial)
const solidMesh = new THREE.Mesh(geometry, solidMaterial)
scene.add(solidMesh)
scene.add(humbelMesh)

const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000)
camera.position.z = 20

const renderer = new THREE.WebGLRenderer()
renderer.setSize(window.innerWidth, window.innerHeight)

const animate = () => {
  requestAnimationFrame(animate)
  humbelMesh.rotation.x += 0.01
  humbelMesh.rotation.y += 0.01
  solidMesh.rotation.x += 0.01
  solidMesh.rotation.y += 0.01
  renderer.render(scene, camera)
}

onMounted(() => {
  new OrbitControls(camera, renderer.domElement)
  document.getElementById('circlegeometry')?.appendChild(renderer.domElement)
  animate()
})
window.onresize = () => {
  renderer.setSize(window.innerWidth, window.innerHeight)
  camera.aspect = window.innerWidth / window.innerHeight
  camera.updateProjectionMatrix()
}
</script>

<style>

</style>